package decisionalalgorithms.guialgorithms.converters;

import com.sun.istack.Nullable;
import decisionalalgorithms.guialgorithms.commands.PriorityCommand;
import decisionalalgorithms.guialgorithms.domain.Priority;
import lombok.Synchronized;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

@Component
public class PriorityToPriorityCommand implements Converter<Priority, PriorityCommand> {
    @Synchronized
    @Nullable
    @Override
    public PriorityCommand convert(Priority source) {
        if (source == null) {
            return null;
        }
        final PriorityCommand priorityCommand = new PriorityCommand();
        priorityCommand.setId(source.getId());
        priorityCommand.setPriority(source.getPriority());
        return priorityCommand;
    }
}
